import http from "@/utils/http";
import { AxiosRequestConfig } from "axios";

export interface PostSubjects_ {
  /**
   * @description parentId
   * @format int32
   */
  parentId: number;
  /**
   * @description previousId
   * @format int32
   */
  previousId: number;
  /**
   * @description subjectLevel
   * @format int32
   */
  subjectLevel: number;
  /**
   * @description subjectName
   */
  subjectName: string;
}
export interface GetSubjectsList_ {
  /**
   * @description 审核状态的数字编号列表。1：草稿，2：创建审核中，3：未发布，4：发布审核中，5：已发布
   */
  reviewStatusList?: number[];
}
export interface PutSubjectsById_ {
  /**
   * @description subjectName
   */
  subjectName: string;
  /**
   * @description 主键id
   * @format int32
   * @example 1
   */
  id: number;
}
export interface DeleteSubjectsById_ {
  /**
   * @description id
   */
  id: number;
}

export class Subject {
  /**
   * 添加主题
   *
   * @tags 主题controller
   * @request POST: /subjects
   * @secure
   */
  postSubjects = (
    query: { parentId: number; previousId: number; subjectLevel: number; subjectName: string } | PostSubjects_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntitySubjectVO>({
      url: `/subjects`,
      method: "POST",
      params: query,
      ...params,
    });

  /**
   * 全部主题一级主题
   *
   * @tags 主题controller
   * @request GET: /subjects/first-level
   * @secure
   */
  getSubjectsFirstLevel = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListSubjectDropListVO>({
      url: `/subjects/first-level`,
      method: "GET",
      ...params,
    });

  /**
   * 全部主题的查询
   *
   * @tags 主题controller
   * @request GET: /subjects/list
   * @secure
   */
  getSubjectsList = (query: { reviewStatusList?: number[] } | GetSubjectsList_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntitySubjectVO>({
      url: `/subjects/list`,
      method: "GET",
      params: query,
      ...params,
    });

  /**
   * 全部主题的查询, 下拉三级主题
   *
   * @tags 主题controller
   * @request GET: /subjects/simple-list
   * @secure
   */
  getSubjectsSimpleList = (params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityListOptionVO>({
      url: `/subjects/simple-list`,
      method: "GET",
      ...params,
    });

  /**
   * 更新主题名称
   *
   * @tags 主题controller
   * @request PUT: /subjects/{id}
   * @secure
   */
  putSubjectsById = (
    { id, ...query }: { subjectName: string; id: number } | PutSubjectsById_,
    params: AxiosRequestConfig = {},
  ) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/subjects/${id}`,
      method: "PUT",
      params: query,
      ...params,
    });

  /**
   * 删除主题
   *
   * @tags 主题controller
   * @request DELETE: /subjects/{id}
   * @secure
   */
  deleteSubjectsById = ({ id }: { id: number } | DeleteSubjectsById_, params: AxiosRequestConfig = {}) =>
    http.request<defs.ResponseEntityBoolean>({
      url: `/subjects/${id}`,
      method: "DELETE",
      ...params,
    });
}

export default new Subject();
